
package com.catsic.zcjc.web.controller;


import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.catsic.base.controller.BaseController;
import com.catsic.zcjc.entity.City;
import com.catsic.zcjc.entity.District;
import com.catsic.zcjc.entity.Province;
import com.catsic.zcjc.service.CityService;
import com.catsic.zcjc.service.DistrictService;
import com.catsic.zcjc.service.ProvinceService;


@Controller
@RequestMapping("/area")
public class AreaController extends BaseController{
	
	@Autowired
	private ProvinceService provinceService;
	
	@Autowired
	private CityService cityService;
	
	@Autowired
	private DistrictService districtService;
	
	
  
	
	/**
	 * provinceList:省份列表
	 * @author xietiebing
	 * @param 
	 * @return
	 */
	@RequestMapping(value = "/provinceList" , method = RequestMethod.GET)
	@ResponseBody
	public Map<String,Object> provinceList(){
		List<Province> list = provinceService.findAll();
		
		Map<String,Object> map = new HashMap<String,Object>(); 
		map.put(CONTENT, list);
		map.put(RESULT, RESULT_SUCCESS);
		return map;
	}
	
	/**
	 * cityList:城市列表
	 * @author xietiebing
	 * @param 
	 * @return
	 */
	@RequestMapping(value = "/cityList" , method = RequestMethod.GET)
	@ResponseBody
	public Map<String,Object> cityList(Long provinceId){
		List<City> list = cityService.findByProvince(provinceId);
		
		Map<String,Object> map = new HashMap<String,Object>(); 
		map.put(CONTENT, list);
		map.put(RESULT, RESULT_SUCCESS);
		return map;
	}
	
	/**
	 * districtList:区县列表
	 * @author xietiebing
	 * @param 
	 * @return
	 */
	@RequestMapping(value = "/districtList" , method = RequestMethod.GET)
	@ResponseBody
	public Map<String,Object> districtList(Long cityId){
		List<District> list = districtService.findByCity(cityId);
		
		Map<String,Object> map = new HashMap<String,Object>(); 
		map.put(CONTENT, list);
		map.put(RESULT, RESULT_SUCCESS);
		return map;
	}
}
